﻿using System;
using Modules.Project;
using Modules.Reports;
using Modules.System.Settings.Entitys;
using Modules.System.Settings;
using PetaPoco;
using PmSoft;
using PmSoft.Caching;
using static Modules.Project.ProjectConstants;
using System.ComponentModel;

namespace Modules
{
    /// <summary>
    /// 项目月统计报表
    ///</summary>
    [TableName("report_project_month")]
    [Description("项目信息月统计表")]
    [PrimaryKey("id", AutoIncrement = true)]
    [CacheSetting(true, PropertyNamesOfArea = "ProjectId")]
    [Serializable]
    public class ReportProjectMonth : IEntity
    {
        /// <summary>
        /// 主键
        ///</summary>
        [Column("id")]
        public int Id { get; set; }

        /// <summary>
        /// 统计月份
        ///</summary>
        [Column("month")]
        public int Month { get; set; }

        /// <summary>
        /// 项目id
        ///</summary>
        [Column("project_id")]
        public int ProjectId { get; set; }

        /// <summary>
        /// 项目名称
        ///</summary>
        [Column("project_name")]
        public string ProjectName { get; set; }

        /// <summary>
        /// 专户状态
        ///</summary>
        [Column("special_account_status")]
        public 落实状态 SpecialAccountStatus { get; set; }

        /// <summary>
        /// 考勤状态
        ///</summary>
        [Column("checkin_status")]
        public 落实状态 CheckinStatus { get; set; }

        /// <summary>
        /// 代发状态
        ///</summary>
        [Column("wage_status")]
        public 落实状态 WageStatus { get; set; }

        /// <summary>
        /// 进账状态
        ///</summary>
        [Column("income_status")]
        public 落实状态 IncomeStatus { get; set; }

        /// <summary>
        /// 关键岗位考勤状态
        ///</summary>
        [Column("key_position_checkin_status")]
        public 落实状态 KeyPositionCheckinStatus { get; set; }

        /// <summary>
        /// 项目当月在建天数
        ///</summary>
        [Column("days_this_month_under_construction")]
        public int DaysThisMonthUnderConstruction { get; set; }

        /// <summary>
        /// 项目累计在建天数
        ///</summary>
        [Column("days_under_construction")]
        public int DaysUnderConstruction { get; set; }

        /// <summary>
        /// 项目当月停工天数
        ///</summary>
        [Column("days_this_month_shut_down")]
        public int DaysThisMonthShutDown { get; set; }

        /// <summary>
        /// 项目累计停工天数
        ///</summary>
        [Column("days_shut_down")]
        public int DaysShutDown { get; set; }

        /// <summary>
        /// 对口部门
        ///</summary>
        [Column("counterpart_department")]
        public byte CounterpartDepartment { get; set; }

        /// <summary>
        /// 应进账总额
        ///</summary>
        [Column("total_amount_due")]
        public decimal TotalAmountDue { get; set; }

        /// <summary>
        /// 实际进账总额
        ///</summary>
        [Column("total_actual_receipts")]
        public decimal TotalActualReceipts { get; set; }

        /// <summary>
        /// 理论余额
        ///</summary>
        [Column("theoretical_balance")]
        public decimal TheoreticalBalance { get; set; }

        /// <summary>
        /// 线上代发金额
        ///</summary>
        [Column("online_amount")]
        public decimal OnlineAmount { get; set; }

        /// <summary>
        /// 线下代发金额
        ///</summary>
        [Column("offline_amount")]
        public decimal OfflineAmount { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        [Column("create_time")]
        public DateTime CreateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 当前实际施工月
        /// </summary>
        [Column("current_actual_construction_months")]
        public decimal CurrentActualConstructionMonths { get; set; }

        /// <summary>
        /// 总工期
        /// </summary>
        [Column("total_duration")]
        public int TotalDuration { get; set; }

        /// <summary>
        /// 应考勤人数
        /// </summary>
        [Column("number_attendance_required")]
        public int NumberAttendanceRequired { get; set; }

        /// <summary>
        /// 实际考勤人数
        /// </summary>
        [Column("actual_attendance")]
        public int ActualAttendance { get; set; }

        /// <summary>
        /// 实际代发笔数
        /// </summary>
        [Column("number_agency_transactions")]
        public int NumberAgencyTransactions { get; set; } = 0;

        /// <summary>
        /// 实际代发金额
        /// </summary>
        [Column("payment_amount")]
        public decimal PaymentAmount { get; set; } = 0M;

        /// <summary>
        /// 实际代发人数
        /// </summary>
        [Column("number_proxy_recipients")]
        public int NumberProxyRecipients { get; set; } = 0;

        /// <summary>
        /// 工资专户余额(元)
        /// </summary>
        [Column("Balance")]
        public decimal Balance { get; set; } = 0M;

        /// <summary>
        /// 项目经理考勤天数
        /// </summary>
        [Column("project_manager_attendance_days")]
        public int ProjectManagerAttendanceDays { get; set; } = 0;

        /// <summary>
        /// 技术负责人考勤天数
        /// </summary>
        [Column("technical_manager_attendance_days")]
        public int TechnicalManagerAttendanceDays { get; set; }

        /// <summary>
        /// 安全员考勤天数
        /// </summary>
        [Column("safety_officer_attendance_days")]
        public int SafetyOfficerAttendanceDays { get; set; }

        /// <summary>
        /// 总监理工程师考勤天数
        /// </summary>
        [Column("supervision_attendance_days")]
        public int SupervisionAttendanceDays { get; set; }

        /// <summary>
        /// 最后更新时间
        /// </summary>
        [Column("update_time")]
        public DateTime? UpdateTime { get; set; } = DateTime.Now;

        #region IEntity 成员

        [Ignore]
        object IEntity.EntityId { get { return this.Id; } }

        #endregion IEntity 成员
    }

    public static class ReportProjectMonthExtensions
    {
    }
}